package com.okwanshiwu.payment;

import com.okwanshiwu.payment.aliUtil.AliPayUtil;
import com.okwanshiwu.payment.aliUtil.AlipayType;
import com.okwanshiwu.payment.common.PayType;
import com.okwanshiwu.payment.wxUtil.WxPayUtil;
import com.okwanshiwu.payment.wxUtil.WxpayType;
import com.okwanshiwu.pojo.pay.CommonResult;

import java.util.Map;

/**
 * 支付方式--外观模式
 *
 * @author
 * @create 2017-07-31 14:49
 **/
public class PayTypeMaker {

	/**
	 * 获取支付的实现类
	 * @param type 类型  aliPay wxPay
	 * @return
	 */
	public static PayType getPayType(String type){
		PayType payType = null;
		switch (type){
			case "aliPay":
				payType = new AlipayType();
				break;
			case "wxPay":
				payType = new WxpayType();
				break;
			default:

		}
		return payType;
	}

	/**
	 * 将数据进行验证和清理
	 * @param map  数据
	 * @param type 类型  aliPay wxPay
	 * @return
	 */
	public static CommonResult getCallBackMap(Map map, String type){
		CommonResult cleanedData = null;
		switch (type){
			case "aliPay":
				cleanedData = WxPayUtil.cleanData(map);
				break;
			case "wxPay":
//				cleanedData = AliPayUtil.cleanData(map);
				break;
			default:
		}
		return cleanedData;
	}

}
